<template>
<div> 
    <slot name="header"></slot>
    学校名称:{{name}},
    学校地址:{{address}}
 <slot name="footer"></slot>
</div>
</template>

<script>
import pubsub from 'pubsub-js';
   export default {
        name:  'School',
        props:['schoolName'],
        data(){
            return{
            name:"兰州理工大学",
            address:"甘肃"
            }
        },
        components: {},
        methods:{
         getDataFromStudent(messagename,data){
   // console.log("我是school组件,我收到了值"+data);
   console.log('有人发布了hello消息,消息的回调执行了',messagename,data);
         }
        },
    mounted() {
        //绑定一个自定义事件
       // this.$bus.$on('test',this.getDataFromStudent);
       //订阅消息,subscribe(消息名称，消息的回调函数)
     this.pubId=pubsub.subscribe('hello',this.getDataFromStudent)
    },
    beforeDestroy(){
        //this.$bus.$off("test");
      pubsub.unsubscribe(this.pubId);
    }
   }
</script>

<style scoped>

</style>